[#escape x as x?html]
<!DOCTYPE html>
<html>
<head>
	[#include "/include/meta.ftl" /]
	[#include "/include/css.ftl" /]
    <title>文章</title>
	[#include "/include/js.ftl" /]
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

    <div class="content-wrapper margin-left0">
		[#assign firstNavName="文章"]
		[#assign secondNavName="编辑"]
		[#include "/include/contentHeader.ftl" /]

			<section class="content">
				<div class="box box-success">
					<form id="form" action="${base}/admin/article/update" method="post" class="form-horizontal">
                        <input type="hidden" name="fileId" id="fileId">
                        <input type="hidden" name="articleClassIds" id="articleClassIds">
                        <input type="hidden" name="contentHtml" id="contentHtml" value="${article.contentHtml}">
                        <input type="hidden" name="contentText" id="contentText" value="${article.contentText}">
						<input type="hidden" name="id" value="${article.id}"/>
						<div class="box-body">
			                <div class="form-group">
		                  		<label class="col-sm-2 control-label">标题</label>
								<div class="col-sm-6">
								  <input type="text" name="title" value="${article.title}" class="form-control" placeholder="标题">
								</div>
			                </div>
						</div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">作者</label>
                                <div class="col-sm-6">
                                    <input type="text" name="author" class="form-control" placeholder="作者" value="${article.author}">
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分类</label>
                                <div class="col-sm-6">
									[#list articleClasses as articleClass]
                                        <label>
                                            <input name="articleClassId" type="checkbox" value="${articleClass.id}"
												   [#if article.containsClass(articleClass)]checked=""[/#if]>
										${articleClass.name}
                                        </label>
									[/#list]

								[#--<div class="checkbox">
                                    <label>
                                        <input type="checkbox" disabled="">
                                        Checkbox disabled
                                    </label>
                                </div>--]
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">主图</label>
                                <div class="col-sm-6" id="uploadFile" style="display: [#if article.mainPic??]none[#else]block[/#if]">
                                    <input type="file" name="file" id="mainPic"
                                           accept="image/jpg,image/jpeg,image/png,image/gif">
                                </div>
                            </div>
                            <div class="form-group" id="uploadedFile">
                                <label class="col-sm-2 control-label">预览</label>
                                <div class="col-sm-5">
                                    <img id="imgContent" width="400px"  [#if article.mainPic??]src="${base}/${article.mainPic.path}"[#else][/#if]/>
                                </div>
                                <div class="col-sm-1">
                                    <button id="deletePhoto" type="button"
                                            class="btn btn-block btn-danger"  style="display: [#if article.mainPic??]block[#else]none[/#if]">删除照片
                                    </button>
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否显示</label>
                                <div class="col-sm-6">
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="display" value="true" [#if article.display]checked=""[/#if]>是
                                        </label>
                                        &nbsp;&nbsp;
                                        <label>
                                            <input type="radio" name="display" value="false" [#if !article.display]checked=""[/#if]>否
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否置顶</label>
                                <div class="col-sm-6">
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="top" value="true" [#if article.top]checked=""[/#if]>是
                                        </label>
                                        &nbsp;&nbsp;
                                        <label>
                                            <input type="radio" name="top" value="false" [#if !article.top]checked=""[/#if]>否
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">文章状态</label>
                                <div class="col-sm-6">
                                    <div class="radio">
                                        <label>
                                            <input type="radio" name="status" value="-1" [#if article.status == -1]checked=""[/#if]>已删除
                                        </label>
                                        &nbsp;&nbsp;
                                        <label>
                                            <input type="radio" name="status" value="1" [#if article.status == 1]checked=""[/#if]>草稿
                                        </label>
                                        &nbsp;&nbsp;
                                        <label>
                                            <input type="radio" name="status" value="0" [#if article.status == 0]checked=""[/#if]>发布
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">文章详情</label>
                                <div class="col-sm-10">
                                    <!-- 加载编辑器的容器 -->
                                    <script id="editor" type="text/plain" name="content">
                                        [#noescape]${article.contentHtml}[/#noescape]
                                    </script>
                                </div>
                            </div>
                        </div>

						<div class="box-footer">
							<div class="row">
								<div class="col-sm-offset-2">
		                			<button id="btnSubmit" type="button" class="btn btn-primary">保存</button>
								</div>
							</div>
		                </div>
					</form>
				</div>
			</section>
		</div>

	</div>
	<!-- ./wrapper -->
	<script type="text/javascript">
		window.UEDITOR_HOME_URL = _base + '/resource/public/plugin/ueditor/';
        require(['admin/js/article/add', 'jquery'], function (Page, $) {
            Page.main();
        });
	</script>
</body>
</html>
[/#escape]
